/**
 * v-auth
 * 按钮权限指令
 */
import type { Directive, DirectiveBinding } from "vue";
import { useUserStore } from "@/stores/modules/user";

const auth: Directive = {
  mounted(el: HTMLElement, binding: DirectiveBinding) {
    const userStore = useUserStore();
    const { value } = binding;
    if (!userStore.userInfo?.isSuperAdmin && !userStore.userInfo?.perms.includes(value)) {
      el.remove();
    }
  }
};

export default auth;
